using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using BA.DAL;

namespace BlazeApps.Library.Messaging
{
    public class Inbox : Base
    {
        private BA.DAL.DBUtility DAL = new BA.DAL.DBUtility();
        private Procedures Procs = new Procedures();

        public DataTable GetInboxList(Guid UserID)
        {
            DAL.CreateDBObjects(ConnectionString, Provider);

            DAL.AddParameter("@userid", UserID);

            return DAL.GetDataTable(Procs.ListPrivateMessageInboxItems.ToString().Trim(), CommandType.Text, ConnectionState.Open);
        }

        public Int32 GetInboxCount(Guid UserID)
        {
            DataRow row;
            DAL.CreateDBObjects(ConnectionString, Provider);

            DAL.AddParameter("@userid", UserID);

            row = DAL.GetDataTable(Procs.ListPrivateMessageCountByUserID.ToString().Trim(), CommandType.Text, ConnectionState.Open).Rows[0];

            return Convert.ToInt32(row["newmessages"]);
        }
        
    }
}
